<script setup>
import {onMounted, ref} from "vue";
import request5151 from "../../../utils/request5151.js";
import {ElMessage} from "element-plus";
// loading
const loading = ref(true)
// 录取信息数据
const admissionInfosData = ref()
//搜索数据
const searchData = ref({
  snumber: '',
  admissionStatus: '',
  classes: '',
  profession: '',
})
// 分页相关
let pageNum = 1
let pageSize = 15
const total = ref(0)
const handleSizeChange = (val) => {
  pageSize = val
  getAdmissionInfos()
}
const handleCurrentChange = (val) => {
  pageNum = val
  getAdmissionInfos()
}
// 获取录取信息
const getAdmissionInfos = () => {
  request5151({
    url: '/admissioninfo/getAll',
    method: 'get',
    params: {
      pageNumber: pageNum,
      pageSize: pageSize,
      sNumber: searchData.value.snumber ? searchData.value.snumber : null,
      admissionStatus: searchData.value.admissionStatus ? searchData.value.admissionStatus : null,
      classes: searchData.value.classes ? searchData.value.classes : null,
      profession: searchData.value.profession ? searchData.value.profession : null,
    }
  }).then((res) => {
    if (res.data.code === 200) {
      admissionInfosData.value = res.data.data.records
      total.value = res.data.data.total
      loading.value = false
    }
  }).catch(() => {
    ElMessage.error('请求失败')
    loading.value = false
  })

}
getAdmissionInfos()
</script>

<template>
  <div class="admissionInfosAll">
    <!--面包屑-->
    <el-breadcrumb separator="/" style="margin-bottom: 20px;">
      <el-breadcrumb-item><b>迎新信息管理</b></el-breadcrumb-item>
      <el-breadcrumb-item>录取信息列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!--搜索条件-->
    <el-form :inline="true" :model="searchData" class="demo-form-inline">
      <el-form-item label="学号">
        <el-input v-model="searchData.snumber" placeholder="输入学号" clearable/>
      </el-form-item>
      <el-form-item label="状态" style="width: 200px;">
        <el-select
            v-model="searchData.admissionStatus"
            clearable
        >
          <el-option label="已录取" value="已录取"/>
          <el-option label="未录取" value="未录取"/>
        </el-select>
      </el-form-item>
      <el-form-item label="班级">
        <el-input v-model="searchData.classes" placeholder="输入班级" clearable/>
      </el-form-item>
      <el-form-item label="专业">
        <el-input v-model="searchData.profession" placeholder="输入专业" clearable/>
      </el-form-item>
      <el-button type="success" @click="getAdmissionInfos" style="margin-bottom: 20px;">查询</el-button>
    </el-form>
    <!--数据-->
    <el-table :data="admissionInfosData" v-loading="loading"
              empty-text="暂无数据" element-loading-text="数据加载中...">
      <el-table-column prop="snumber" label="学号" width="150"/>
      <el-table-column prop="profession" label="专业"/>
      <el-table-column prop="classes" label="班级"/>
      <el-table-column prop="admissionDate" label="录取时间"/>
      <el-table-column prop="admissionStatus" label="录取结果">
        <template #default="scope">
            <span style="color: green" v-if="scope.row.admissionStatus==='已录取'">{{
                scope.row.admissionStatus
              }}</span>
          <span style="color: red" v-else>{{ scope.row.admissionStatus }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <el-pagination background layout="prev,sizes, pager, next"
                   :page-sizes="[6,10]"
                   :total="total"
                   :page-size="pageSize"
                   @size-change="handleSizeChange"
                   @current-change="handleCurrentChange"

    />
  </div>
</template>

<style scoped>

</style>
